import request from '@/utils/request'

// 查询报表组件列表
export function listReport(query) {
  return request({
    url: '/report/list',
    method: 'get',
    params: query
  })
}

// 查询报表组件详细
export function getReport(reportId) {
  return request({
    url: '/report/info',
    method: 'get',
    params: {
      reportId: reportId
    }
  })
}

// 新增报表组件
export function addReport(data) {
  return request({
    url: '/report',
    method: 'post',
    data: data
  })
}

// 修改报表组件
export function updateReport(data) {
  return request({
    url: '/report',
    method: 'put',
    data: data
  })
}

// 删除报表组件
export function delReport(reportId) {
  return request({
    url: '/report/' + reportId,
    method: 'delete'
  })
}

// 获取db列表
export function getDbList() {
  return request({
    url: '/report/dblist',
    method: 'get'
  })
}

// 获取表列表
export function getTableList(dbName) {
  return request({
    url: '/report/tablelist',
    method: 'get', 
    params: {
      dbName: dbName
    }
  })  
}

// 获取表字段列表
export function getColumnList(dbName, tableName) {
  return request({
    url: '/report/columnlist',
    method: 'get',
    params: {
      dbName: dbName,
      tableName: tableName
    }
  })
}

// 验证sql
export function validateSql(data) {
  return request({
    url: '/report/validateSql',
    method: 'post',
    data: data
  })
}

// 生成图表
export function generateChart(data) {
  return request({
    url: '/report/generateChart',
    method: 'post',
    data: data,
    timeout: 100000
  })
}